<{include file="head.html"}>
<div class="public_main">
    <p style="margin:5px 0 0 5px ;height:15px;line-height: 15px;padding: 0;">
        <{foreach $commo_info.typeparents as $k=>$v}>
        <a href="<{$config.SITE_URL}>/type.php?id=<{$k}>" style="text-decoration: none;"><{$v}></a> &gt;  
        <{/foreach}>
        <{$commo_info.typename}>
    </p>
    <div class="commo_left">
        <div class="commo_left_box">
            <div class="commo_left_mt">
                <h3>当前分类热卖</h3>
            </div>
            <div class="commo_left_md">
                <ul>
                    <{section name=typehotsell loop=$typehotsell}>
                    <li><a href="<{$config.SITE_URL}>/commo.php?id=<{$typehotsell[typehotsell].id}>"><{$typehotsell[typehotsell].name}></a></li>
                    
                    <{/section}>
                </ul>
            </div>
        </div>
        <div class="commo_left_box">
            <div class="commo_left_mt">
                <h3>当前分类最新商品</h3>
            </div>
            <div class="commo_left_md">
                <ul>
                    <{section name=typenew loop=$typenew}>
                    <li><a href="<{$config.SITE_URL}>/commo.php?id=<{$typenew[typenew].id}>"><{$typenew[typenew].name}></a></li>
                    
                    <{/section}>
                </ul>
            </div>
        </div>
    </div>
    <div class="commo_right">
        <{* 商品信息概览 *}>
        <div class="commo_info">
            <{*图册*}>
            
            <div class="commo_info_pic">
                <div id="commopic">
                    <div id="commopic_bg"></div>
                    <div id="commopic_info">鼠标悬浮放大镜</div>
                    <ul>
                        <{section name=commo_pics loop=$commo_pics max=4}>
                            <{if $smarty.section.commo_pics.first}>
                                <li class="on"><{$smarty.section.commo_pics.iteration}></li>
                            <{else}>
                            <li><{$smarty.section.commo_pics.iteration}></li>
                            <{/if}>
                        <{/section}>
                        
                            
                    </ul>
                    
                    <div id="commopic_list">
                        
                        <{section name=commo_pics_1 loop=$commo_pics max=4}>
                        <a href="<{$commo_pics[commo_pics_1]}>" class="jqzoom"><img src="<{$commo_pics[commo_pics_1]}>" width="320" height="300"/></a>
                        <{/section}>
                        
                    </div>
                    <script>
                        var t = n = 0, count;
                        $(document).ready(function(){    
                            count=$("#commopic_list a").length;
                            $("#commopic_list a:not(:first-child)").hide();
                            //$("#commopic_info").html($("#commopic_list a:first-child").find("img").attr('alt'));
                            //$("#commopic_info").click(function(){window.open($("#commopic_list a:first-child").attr('href'), "_blank")});
                            $("#commopic li").click(function() {
                                var i = $(this).text() - 1;//获取Li元素内的值，即1，2，3，4
                                n = i;
                                if (i >= count) return;
                                $("#commopic_info").html($("#commopic_list a").eq(i).find("img").attr('alt'));
                                //$("#commopic_info").unbind().click(function(){window.open($("#commopic_list a").eq(i).attr('href'), "_blank")})
                                $("#commopic_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
                                document.getElementById("commopic").style.background="";
                                $(this).toggleClass("on");
                                $(this).siblings().removeAttr("class");
                            });
                            t = setInterval("showAuto()", 4000);
                            $("#commopic").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});
                        })

                        function showAuto()
                        {
                            n = n >=(count - 1) ? 0 : ++n;
                            $("#commopic li").eq(n).trigger('click');
                        }
                    </script>
                    <script>
                    $(function(){
                        $(".jqzoom").jqzoom({zoomWidth:300,zoomHeight:300,title:false});
                    })
                    </script>
                </div>
            </div>
            <div class="commo_info_infos">
                <div class="commo_info_title"><b><{$commo_info.name}></b> <{$commo_info.seoname}></div>
                <div class="commo_info_ul">
                    <table style="border:0;margin:0;padding:0;">
                        <tr>
                            <td>市场价:</td><td><span style="color:red"> <{$commo_info.price}> </span>元</td>
                        </tr>
                        
                        <{if $commo_info.discount>0}>
                        <tr>
                            <td><font color="red">促销价：</font></td><td><b style="color:red"><{$commo_info.vprice*$commo_info.discount/10}></b> 元 <font size="1" color="green">帮您节省 <b style="color:Red"><{$commo_info.price-$commo_info.vprice*$commo_info.discount/10}></b> 元</font></td>
                        </tr>
                        <{else}>
                        <tr>
                            <td>会员价:</td><td> <b style="color:green"><{$commo_info.vprice}></b> 元 <font size="1" color="green">帮您节省 <b style="color:Red"><{$commo_info.price-$commo_info.vprice}></b> 元</font></td>
                        </tr>
                        <{/if}>
                        <tr>
                            <td>已销售:</td><td><{$commo_info.sell}>件</td>
                        </tr>
                        <tr>
                            <td>库&nbsp;&nbsp;&nbsp;&nbsp;存:</td><td><{$commo_info.stock}>件</td>
                        </tr>
                        <tr>
                            <td>购买数量</td>
                            <td><input type="text" style="width: 30px;" value="1" id="buycount"/></td>
                        </tr>
                        <tr><td colspan="2"><span class="btn"><a href="javascript:void(0)" onclick="buy(<{$commo_info.id}>)">加入购物车</a></span></td><td colspan="2"><span class="btn"><a href="javascript:void(0)" onclick="addfavorite(<{$commo_info.id}>)">加入收藏</a></span></td></tr>
                    </table>
                    <div style="width: 100%;height:70px;background-color:#f1f1e3 ;" id="gmxz"><h3><font color="red">购买须知</font></h3><p>喜欢该宝贝？可点击收藏哦，在个人中心里可以看到宝贝收藏夹！直接购买请点击加入购物车！</p></div>
                    <div id="buysuccess" style="width: 250px;height: 65px;border:3px #316ac5 solid;position: relative;left:0;top:-80px;background-color: white;z-index: 1001;display: none; ">
                        <p style="text-align: center">恭喜！加入购物车成功！</p>
                        <p style="text-align: center"><a href="<{$config.SITE_URL}>/cart.php">立即付款</a>  <a href="javascript:void(0)" onclick="$('#buysuccess').fadeOut(1000)">继续购物</a></p>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            function buy(id){
                $.ajax({
                    url:'<{$config.SITE_URL}>/ajax.php?action=buy&commoid=<{$commo_info.id}>&count='+$("#buycount").val(),
                    cache:false,
                    timeout:10000,
                    beforeSend:function(){
                      $("#buysuccess").hide();  
                    },
                    error:function(XMLHttpRequest,textStatus){
                            if(textStatus=='timeout'){
                                alert('请求超时，请重试！');
                            }else{
                                alert('请求失败');
                            }
                        },
                    success:function(html){
                        if(html=="0"){
                            $("#buysuccess").fadeIn(500);
                        }else if(html=="1"){
                            alert('加入购物车失败，非法提交');
                        }else if(html=="2"){
                            alert('宝贝不存在，或已下架');
                        }else if(html=="3"){
                            alert('库存不足');
                        }else{
                            alert('加入购物车失败，未知错误');
                        }
                    }
                })
            }
            function addfavorite(commoid){
                $.ajax({
                    url:'<{$config.SITE_URL}>/ajax.php?action=addfav&commoid='+commoid,
                    cache:false,
                    timeout:10000,
                    error:function(XMLHttpRequest,textStatus){
                            if(textStatus=='timeout'){
                                alert('请求超时，请重试！');
                            }else{
                                alert('请求失败');
                            }
                           },
                    success:function(html){
                        if(html!=''){
                            alert(html);
                        }
                        
                    }       
                        
                })
            }
        </script>
        <{* 商品描述 *}>
        <div class="commo_des">
            <div class="mt">
                商品简介
            </div>
            <div class="md">                                
                <{$commo_info.info}>
            </div>
        </div>
    </div>
</div>
<{include file="foot.html"}>
